
#pragma once
#include "SSCalculator.h"
#include "YieldCurveModule/GeneralStatistics.h"
using namespace SS;

class SSCALCULATOR_API CSSGeneralStatistics {
 public:
  CSSGeneralStatistics(void);

  CSSGeneralStatistics(std::vector<double>& samples);

  ~CSSGeneralStatistics(void);

  GeneralStatistics& GetStatistics() { return *m_pStatics; };

  // Number of samples collected
  std::size_t Samples() const;

  // Adds a datum to the set, possibly with a weight
  void Add(double value, double weight = 1.0);

  // Collected data
  const std::vector<std::pair<double, double> >& Data() const;

  // Sum of data weights
  double WeightSum() const;

  // Returns the mean, defined as
  double Mean() const;

  double Variance() const;

  // Returns the standard deviation 'sigma', defined as the square root of the
  // variance.
  double StandardDeviation() const;

  // Returns the minimum sample value */
  double Min() const;

  // Returns the maximum sample value */
  double Max() const;

  // Return distribution frequency information, normal distribution points
  int GetDistributionInfo(std::vector<DistributionInfo>& distInfoVec,
                          std::vector<NormalCurvePoint>& normalCurvePoints,
                          int nPoints);

 protected:
  GeneralStatistics* m_pStatics;
};

// Calculate correlation
double SSCALCULATOR_API AfxCorrelation(CSSGeneralStatistics& m1,
                                       CSSGeneralStatistics& m2);

// Calculate covariance
double SSCALCULATOR_API AfxCovariance(CSSGeneralStatistics& m1,
                                      CSSGeneralStatistics& m2);
